-
Notifications
You must be signed in to change notification settings - Fork 192
Added getters for JsonPatch and Operations #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I'm also highly interested in this PR getting merged, getters would be really useful for examining the operations (in my use-case: checking for certain paths to discourage changes to some part of the json document) |
My use case is similar to @Spellmaker but notably different. We have JSON models that map to database models where only some fields are mutable via our REST API. We need to be able to examine a patch request in order to validate that the JSON paths are mutable according to business policy. While we could do this with raw JSON and then parse it into a As far as this PR, it seems innocuous as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall.
@@ -94,6 +94,14 @@ protected JsonPatchOperation(final String op, final JsonPointer path) | |||
public abstract JsonNode apply(final JsonNode node) | |||
throws JsonPatchException; | |||
|
|||
public String getOp() { | |||
return op; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this protectively copy the string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't have thought this is necessary as String
is immutable, if I'm not thinking of something can you please explain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you're right.
Thanks for the feedback, addressed all comments with one outstanding |
I am using v.13 (https://mvnrepository.com/artifact/com.github.java-json-tools/json-patch/1.13), but still not able to use method getOperations(). |
We are also interested in having the getOperations accessor and see that it isn't in 1.13 - are there plans for another release that will pick up this change? |
Hoping this gets picked up & released due to recent activity by @Capstan :)
Personal use case is needing to determine which class to patch when using subtypes, and the type info being held in a field which may be modified by a replace operation.
Solves #33
Supercedes #45